<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("faithwar", $con);
date_default_timezone_set("PRC"); //timezone
$dateTime = date("Y-m-d",strtotime("-1 day"));
#$dateTime = date("Y-m-d");

    $deviceid_query = mysql_query("select DISTINCT deviceid,createdate from  faithwar_all where action =3"); //id
    //$deviceid = mysql_fetch_array($deviceid_query);
    //while($deviceid[deviceid])

while($deviceid = mysql_fetch_array($deviceid_query))
{
  $sql = "UPDATE  faithwar_query_temp SET firstlogindata= '$deviceid[createdate]',firstlogin= '$deviceid[createdate]' WHERE deviceid= '$deviceid[deviceid]'";
   if(mysql_query($sql,$con)){
    echo "1 update is ok!";
} else {
    echo "failed".mysql_error();
}

}

      $deviceid2_query = mysql_query("select DISTINCT deviceid,createdate from  faithwar_query_temp where action =3"); //id
    //$deviceid = mysql_fetch_array($deviceid_query);
    //while($deviceid[deviceid])

while($deviceid2 = mysql_fetch_array($deviceid2_query))
{
  $sql2 = "UPDATE  faithwar_query_temp SET firstlogindata= '$deviceid2[createdate]',firstlogin= '$deviceid2[createdate]' WHERE deviceid= '$deviceid2[deviceid]'";
   if(mysql_query($sql2,$con)){
    echo "1 update is ok!";
} else {
    echo "failed".mysql_error();
}

}
    


mysql_close($con);
?>